package com.jason.www.dao;

import com.jason.www.domain.UserRoles;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface UserRolesMapper {
    @Delete({
        "delete from user_roles",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into user_roles (id, user_id, ",
        "roles_id)",
        "values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ",
        "#{rolesId,jdbcType=BIGINT})"
    })
    int insert(UserRoles record);

    @InsertProvider(type=UserRolesSqlProvider.class, method="insertSelective")
    int insertSelective(UserRoles record);

    @Select({
        "select",
        "id, user_id, roles_id",
        "from user_roles",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="roles_id", property="rolesId", jdbcType=JdbcType.BIGINT)
    })
    UserRoles selectByPrimaryKey(Long id);

    @UpdateProvider(type=UserRolesSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(UserRoles record);

    @Update({
        "update user_roles",
        "set user_id = #{userId,jdbcType=BIGINT},",
          "roles_id = #{rolesId,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(UserRoles record);
}